#include "MyGenCreator.hh"
#include <iostream>

MyGenCreator::MyGenCreator()
{
    m_MyGenName = "SimpleParticleGun";
}

MyGenCreator::~MyGenCreator(){}

void* MyGenCreator::CreateNewMyGen(std::string name)
{
    if (m_AvaiableMyGen.find(name) != m_AvaiableMyGen.end())
    {
        m_MyGenName = name;
    }
    else
    {
        std::cout << "Warning!!! MyGen Type \" " << name << " \" NOT FOUND!!! Use default MyGen \" SimpleParticleGun \"." << std::endl;
        std::cout << "Avaiable Type:" << std::endl;
        for(const auto& FPtr:m_AvaiableMyGen)
            std::cout << "  " << FPtr.first << std::endl;
        m_MyGenName = "SimpleParticleGun";
    }

    auto iter = m_AvaiableMyGen.find(m_MyGenName);
    CreateMyGen myGen = iter->second;
    return myGen();
}


